program define fx2_byparty
   version 15.1
	* future: extend to allow label1 label2 and legend
   syntax varlist [if] [pweight], t1(varname) t2(varname) [OPTS(str) ///
	   ALLFIVE LABEL1(str) LABEL2(str)]
	
	marksample touse
	
	if "`weight'" ~= "" {
	   local wt [`weight'`exp']
   }	
	
   forvalues p = 1/3 {
	   di _n(2) "** Party `p' **"
      fx2 `varlist' if `touse' & pid3==`p' `wt',  t1(`t1') t2(`t2') ///
		   `allfive' nodraw
		tempname fx1`p' fx2`p'
      mat `fx1`p'' = r(fx1)
      mat `fx2`p'' = r(fx2)
   }

	* combine three plots horizontally
	local gopts scheme(s1mono) plotregion(style(none)) mlabel ///
	   format(%3.0f) xlabel(0(20)100)
	coefplot (matrix(`fx11'[1,]), ci("`fx11'[5,] `fx11'[6,]") msymbol(O) mlabpos(10))  ///
		(matrix(`fx21'[1,]), ci("`fx21'[5,] `fx21'[6,]") msymbol(Oh) mlabpos(10) /// 
		mcolor(gs8) mlabcolor(gs8)), bylabel(Democrats) ///
		||  ///
		(matrix(`fx12'[1,]), ci("`fx12'[5,] `fx12'[6,]") msymbol(O) mlabpos(10))  ///
		(matrix(`fx22'[1,]), ci("`fx22'[5,] `fx22'[6,]") msymbol(Oh) mlabpos(10) /// 
		mcolor(gs8) mlabcolor(gs8)), bylabel(Independents) ///
		|| ///
		(matrix(`fx13'[1,]), ci("`fx13'[5,] `fx13'[6,]") msymbol(O) mlabpos(10))  ///
		(matrix(`fx23'[1,]), ci("`fx23'[5,] `fx23'[6,]") msymbol(Oh) mlabpos(10) /// 
		mcolor(gs8) mlabcolor(gs8)), bylabel(Republicans) ///
		coeflabel(none = "No Action" low = "Cut 5%" high = "Cut 25%") /// only applies if not all 5
		`gopts' `opts' ///
		byopts(rows(1) legend(off)) subtitle(, fcolor(white))
	
end
